var req;

function AjaxObjectCreate()
{
	if (window.XMLHttpRequest) {
        req = new XMLHttpRequest;
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	return req;
}
function ManagerGeneral(url) 

{	 
     //alert(url);
        var params ={
			'module': 'contact',
            'IsProcess': "Y"
			};
		$.ajax({

				type: "POST",
                url: url,
                data: params,
                dataType: 'text',
				success: function(data){
				$('#paging').html(data);
			   	}
        });

}
function ManagerFavourite(url) 

{	 
     //alert(url);
        var params ={
			'module': 'contact',
            'IsProcess': "Y"
			};
		$.ajax({

				type: "POST",
                url: url,
                data: params,
                dataType: 'text',
				success: function(data){
				$('#Favourite').css('display','none');
			   	}
        });

}
function ManagerDelFav(url) 

{	 
     //alert(url);
        var params ={
			'module': 'contact',
            'IsProcess': "Y"
			};
		$.ajax({

				type: "POST",
                url: url,
                data: params,
                dataType: 'text',
				success: function(data){
				$('#DelFavourite').css('display','none');
			   	}
        });

}
function ManagerGeneralForm(url,formID) 
{	
    //alert(url);
	var params ={
		'module': 'contact'
	};
	var paramsObj = $(frmID).serializeArray();
	$.each(paramsObj, function(i, field){
		params[field.name] = field.value;
	});
		$.ajax({

				type: "POST",
				url: url,
				data: params,
				dataType: 'text',
				success: function(data){
						$('#records_listing').html(data);
				}
		});
}

/*function for forgotpassword starts*/
function submit_form1()
{
	var username = $("#Username").val();
	var login_type = $("#login_type").val();
	
	$.ajax({
	type: 'GET',
	url: 'forgotpass_process.php?action=forgotPass&login_type='+login_type+'&Username='+username,
	success: function(jData){

	$("#myResponse").html(jData);
	
	}

	});
}
/*function for forgotpassword ends*/
/* Newsletter Subscription Starts */
function NewsletterSubscription(formid,url,parameters)
{	
    var pars=$("#"+formid).serialize();
	//var pars=Form.serialize(formid);
    pars=pars+parameters;    
	
	$.ajax({
		   type: 'POST',
		   data: pars,
		   url: url,
		   success: processNewsletterSubscription
		   
		   
		   });
	
}	
function processNewsletterSubscription(originalRequest) 
{
    var x=originalRequest;    
    var temText1=x.substr(0,1);
    var temText2=x.substr(2);	
    if(temText1=="1")
    {				
		MM_goToURL('parent',temText2);
    }
    else
    {
        $('#nl_error_msg').html(temText2);
    }

}
/* Newsletter Subscription Ends */


function getLogin(formid)
{
	var pars=$("#"+formid).serialize();
				
	var url = 'login_process.php?IsProcess=Y';
    	
	$('#response').html('<img src="images/loading.gif">');
    
		$.ajax({
		   type: 'POST',
		   url: url,
		   data: pars,
		   success: ProcessLogin		   
		   });	
		
}

function getLogin2(formid)
{
	var pars=$("#"+formid).serialize();


	$.post('ajax/setcheckoutsession.php',function(data){
	
	
	
	$('#loginform').html('<img src="images/loading.gif">');
    
	$.ajax({
		   type: 'POST',
		   url: 'login_process.php?IsProcess=Y',
		   data: pars,
		   success: ProcessLogin		   
		   });	
	});
	
}

function ProcessLogin(originalRequest) 
{
	if(originalRequest==1)
	{						
		window.location.href='home.php';
	}
	else if(originalRequest==2)
	{						
		window.location.href='profile.php';
	}
	else if(originalRequest==3)
	{						
		window.location.href='checkout.php';
	}
	else
	{
		$('#response').html('');
		$('#response').html(originalRequest);
	}	 	 
}


function UpdateProfile(formid,url,option)
{	
  
    var pars=$("#"+formid).serialize();
	//url= url+"?action="+option;
   	$('#response').html("<img src='images/indicator.gif' border='0'>");
	
	
	$.ajax({
		   type: 'POST',
		   url: url+'?action='+option,
		   data: pars,
		   success: UpdateProfileGeneral
		   
		   
		   });
    	
}	
function UpdateProfileGeneral(originalRequest) 
{
    
    $('#response').html(originalRequest);
}





function clear_serach()
{
	if(document.getElementById('keyWrd').value=='Search')
	{
		document.getElementById('keyWrd').value='';

	}
}



function reset_serach()
{
	if(document.getElementById('keyWrd').value=='')
	{
		document.getElementById('keyWrd').value='Search';
	}
	
}











function bookingAjax(formID)
{

	
	
	var frmID='#'+formID;
	


			var params ={

				'module': 'contact',

				'action': 'sendContactData'

			};

			var paramsObj = j(frmID).serializeArray();

			
			j.each(paramsObj, function(i, field){

				params[field.name] = field.value;



			
			});

		
		
		j.ajax({

				type: "POST",

				url: 'booking_process.php',

				data: params,

				dataType: 'text',
				
				success: function(data){
				
					
					
					
					if (data == 2)

					{

									
							
							window.location.href="thank_you.php";

					}
					else
					{
					 
					 
							j('#errMsg').html(data);
					 
					 
					}

				}

		});

	
}














function contactAjax(formID)
{

	
	
	var frmID='#'+formID;
	


			var params ={

				'module': 'contact',

				'action': 'sendContactData'

			};

			var paramsObj = j(frmID).serializeArray();

			
			j.each(paramsObj, function(i, field){

				params[field.name] = field.value;



			
			});

		
		
		j.ajax({

				type: "POST",

				url: 'contact_process.php',

				data: params,

				dataType: 'text',
				
				success: function(data){
				
					
					
					
					if (data == 2)

					{

						
							
							
							window.location.href="thank_you.php";

					}
					else
					{
					 
					 
							j('#errMsg').html(data);
					 
					 
					}

				}

		});

	
}

function PaginationFront(url)
{	    
    var pars="IsProcess=Y"; 	
	
   $.ajax({
       		type: "GET",
			
			url: url,
			
            data: pars,
            
			dataType: 'text',
			
			success: function(data){
				
					
					var x=data;		
					$('#paging').html(x);  
					num = 0;
					/*StartCycle();*/
				}
        });
}	
function ConfirmDelete(url,delete_id,delete_name,delete_lebel_name) 

{		
   var $ = jQuery.noConflict();

		$.prompt("Delete "+delete_lebel_name+" "+delete_name+" ?",{
		  callback: function(v,m,f){
			    if(v){
		url=url+"&delete_id="+delete_id;	
		//alert(delete_id);
		var params ={
		'module': 'contact',
		'IsProcess':'Y'
		};
		$.ajax({
				type: "POST",
				url: url,
				data: params,
				dataType: 'text',
				success: function(data){
						$('#paging').html(data);

				}

		});
			}
				else
					return false;
		  },
		  buttons:{Ok:true,Cancel:false},
		  prefix:'extblue'
		
	}); 
  }	
 
 function PaginationSearch(page,from,from_page,type)
{
	
	
	if(type == 'undefined' || type=='')
	{	type='';}
	//alert(type);
   var data = {		
		action: 'getSrchResult',
		from_page : from_page,
		from: from,
		type:type,
		IsProcess: 'Y'
   }
   $.ajax({
		  url: page,
		  data: data,
		  type:'POST',
		  dataType: 'html',
		  success:function(res){
			  //alert(res);
			  $('#paging').html(res);
			  }
		  });
   
}
